#ifndef WIFI_MANAGER_H
#define WIFI_MANAGER_H

#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_wifi.h"
#include "esp_http_server.h"

// WiFi配置常量已在esp32_s3_szp.h中定义

// 函数声明
void wifi_provisioning_init(void);
void wifi_start_config_mode(void);
void wifi_connect_sta_auto(const char* ssid, const char* password);
void wifi_connect_sta(const char* ssid, const char* password);
void wifi_init_sta(void);

esp_err_t wifi_save_config(const char* ssid, const char* password);
esp_err_t wifi_load_config(char* ssid, char* password);
bool wifi_is_configured(void);
esp_err_t wifi_clear_config(void);

esp_err_t wifi_scan_networks(wifi_ap_record_t* ap_records, uint16_t* ap_count);

void start_config_webserver(void);
void stop_config_webserver(void);

// HTTP处理函数
esp_err_t config_page_handler(httpd_req_t *req);
esp_err_t wifi_scan_handler(httpd_req_t *req);
esp_err_t wifi_connect_handler(httpd_req_t *req);
esp_err_t config_status_handler(httpd_req_t *req);
esp_err_t wifi_clear_handler(httpd_req_t *req);
esp_err_t wifi_get_config_handler(httpd_req_t *req);

#endif // WIFI_MANAGER_H
